import {
  getLineCodeList,
  getProdOrderStatusList,
  getProdOrderTypeList,
  getPrepositionTypeList,
  getBackflushTypeList,
  getSimulatedTypeList,
} from "@/api/print/mesProdOrder";
// 列表头按钮配置

export const config = {
  data() {
    return {
      operateList: [
        {
          name: $i18n.t("mesTrackingCardPrint.trackingCardPrinting"),
          type: "primary",
          icon: "el-icon-printer",
          handleName: "printBoxCode", // 点击时返回的标识
          isSingle: true, //至少选择一条
          //是否可点击；
          disabled: (data) => {
            return data.length != 1;
          },
        },
        // {
        //   name: $i18n.t("mesTrackingCardPrint.reprint"),
        //   type: "primary",
        //   icon: "el-icon-printer",
        //   handleName: "repairPrint", // 点击时返回的标识
        //   isSingle: true, //至少选择一条
        //   //是否可点击；
        //   disabled: (data) => {
        //     // if (data.length != 1 || !data[0].isCreateBarcode) {
        //     //   return true
        //     // }
        //     if (data.length != 1 || !data[0].isCreateTrackcode) {
        //       return true;
        //     }
        //   },
        // },
      ],
    };
  },
};

// 行末按钮配置
export const rowConfig = [
  {
    name: $i18n.t("common.details"),
    type: "primary",
    class: "row-btn-primary",
    handleName: "show", //点击时返回的标识
  },
];
// 搜索条件配置
export const searchConfig = {
  data() {
    const self = this;
    return {
      searchDialog: {
        inline: true,
        formDesc: {
          orderCode: {
            type: "input",
            label: $i18n.t("mesTrackingCardPrint.orderCode"),
          },
          prodCode: {
            type: "input",
            label: $i18n.t("mesTrackingCardPrint.prodCode"),
          },
          prodOrderType: {
            label: $i18n.t("mesTrackingCardPrint.prodOrderType"),
            type: "select",
            prop: {
              value: "value",
              text: "description",
            },
            options: async (data) => {
              const list = await getProdOrderTypeList();
              return list.data.result;
            },
          },
          planBeginDate: {
            type: "daterange",
            label: $i18n.t("mesTrackingCardPrint.planBeginDate"),
            attrs: {
              valueFormat: "yyyy-MM-dd",
              searchArrKey: ["planBeginDateMin", "planBeginDateMax"],
            },
          },
          lineCode: {
            label: $i18n.t("common.line"),
            type: "select",
            prop: {
              value: "modelingCode",
              text: "modelingName",
            },
            options: async (data) => {
              const params = {
                modelingCode: self.$store.getters.factoryCode,
                level: 5,
              };
              const list = await getLineCodeList(params);
              return list.data.result;
            },
          },
          orderStatus: {
            label: $i18n.t("mesTrackingCardPrint.orderStatus"),
            type: "select",

            prop: {
              value: "value",
              text: "description",
            },
            options: async (data) => {
              const list = await getProdOrderStatusList();
              return list.data.result;
            },
          },
        },
      },
    };
  },
};
// 新增/删除表单配置
export const formDescDialog = {
  span: 24,
  disabled: true,
  isShowSubmitBtn: false,
  labelPosition: "top",
  formDesc: {
    orderCode: {
      type: "input",
      label: $i18n.t("mesTrackingCardPrint.orderCode"),
      layout: 8,
      // disabled: (d) => !!d.id,
      disabled: (data) => {
        return !!data.codeStrategy || !!data.id;
      },
      // required: true,
    },
    planCode: {
      type: "select",
      label: $i18n.t("mesTrackingCardPrint.planCode"),
      layout: 8,
      required: true,
    },

    prodCode: {
      type: "input",
      label: $i18n.t("mesTrackingCardPrint.prodCode"),
      layout: 8,
      required: true,
    },

    prodName: {
      type: "input",
      label: $i18n.t("mesTrackingCardPrint.prodName"),
      layout: 8,
      required: false,
      disabled: true,
    },
    seriesCode: {
      type: "input",
      label: $i18n.t("mesTrackingCardPrint.seriesCode"),
      layout: 8,
      required: true,
      disabled: true,
    },

    seriesName: {
      type: "input",
      label: $i18n.t("mesTrackingCardPrint.seriesName"),
      layout: 8,
      disabled: true,
    },
    measureUnits: {
      type: "input",
      label: $i18n.t("mesTrackingCardPrint.measureUnits"),
      layout: 8,
      disabled: true,
    },
    measureUnitsCode: {
      type: "input",
      label: $i18n.t("mesTrackingCardPrint.measureUnitsCode"),
      layout: 8,
      disabled: true,
    },
    bomVersionNumber: {
      type: "input",
      label: $i18n.t("mesTrackingCardPrint.bomVersionNumber"),
      layout: 8,
      required: false,
    },
    simulatedType: {
      type: "select",
      label: $i18n.t("mesTrackingCardPrint.simulatedType"),
      layout: 8,
      required: true,
      prop: {
        value: "value",
        text: "description",
      },
      options: async (data) => {
        const list = await getSimulatedTypeList();
        return list.data.result;
      },
    },
    prodOrderType: {
      type: "select",
      label: $i18n.t("mesTrackingCardPrint.prodOrderType"),
      layout: 8,
      required: true,
      prop: {
        value: "value",
        text: "description",
      },
      options: async (data) => {
        const list = await getProdOrderTypeList();
        return list.data.result;
      },
    },
    // priority: {
    //   type: 'number',
    //   label: '工单优先级',
    //   layout: 8,
    //   required: true,
    //   min: 1,
    // },
    deliveryDate: {
      type: "date",
      label: $i18n.t("mesTrackingCardPrint.deliveryDate"),
      layout: 8,
      required: false,
      attrs: {
        valueFormat: "yyyy-MM-dd",
      },
    },
    slackTime: {
      type: "number",
      label: $i18n.t("mesTrackingCardPrint.slackTime"),
      layout: 8,
      required: false,
    },
    quantity: {
      type: "number",
      label: $i18n.t("mesTrackingCardPrint.quantity"),
      layout: 8,
      required: true,
    },

    planBeginDate: {
      type: "date",
      label: $i18n.t("mesTrackingCardPrint.planBeginDate"),
      layout: 8,
      required: true,
      attrs: {
        valueFormat: "yyyy-MM-dd",
      },
    },
    planEndDate: {
      type: "date",
      label: $i18n.t("mesTrackingCardPrint.planEndDate"),
      layout: 8,
      required: true,
      attrs: {
        valueFormat: "yyyy-MM-dd",
      },
    },
    // advanceCode: {
    //   type: "input",
    //   label: "提前定单号",
    //   layout: 8,
    //   required: false,
    // },
    backflushType: {
      type: "select",
      label: $i18n.t("mesTrackingCardPrint.backFlushType"),
      layout: 8,
      required: true,
      prop: {
        value: "value",
        text: "description",
      },
      options: async (data) => {
        const list = await getBackflushTypeList();
        return list.data.result;
      },
    },
    prepositionCode: {
      type: "input",
      label: $i18n.t("mesTrackingCardPrint.prepositionCode"),
      layout: 8,
      // required: true,
    },
    prepositionType: {
      type: "select",
      label: $i18n.t("mesTrackingCardPrint.prepositionType"),
      layout: 8,
      // required: true,
      prop: {
        value: "value",
        text: "description",
      },
      options: async (data) => {
        const list = await getPrepositionTypeList();
        return list.data.result;
      },
    },
    remark: {
      type: "textarea",
      label: $i18n.t("common.remark"),
      layout: 24,
      required: false,
    },
  },
};
